﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Reflection;


namespace ModbusTestTool
{
    public abstract class BaseRegister : INotifyPropertyChanged
    {

        // This is so binding list actually fires
        public event PropertyChangedEventHandler PropertyChanged;

        protected void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
            //Type item = typeof(T).GetMethod("Parse").GetType();

        }
        


        /// <summary>
        /// If the valriable has been modified the value get set
        /// </summary>
        public bool dirty { set; get; }
        /// <summary>
        /// THe name of the parameter
        /// </summary>
        public string paramName { set; get; }
        /// <summary>
        /// The base register value is the value without a 3 or 4 in from the number
        /// </summary>
        public int  baseRegister { set; get; }
        /// <summary>
        /// The full register value with the 3 or 4 in front of it
        /// </summary>
        public int register { set; get; }

        /// <summary>
        /// The enum parameterType representing a holding(4x) or a input(3x) register
        /// </summary>
        public enum regType { holding, input };
        /// <summary>
        /// A variable to store if register is float or word
        /// </summary>
        public paramType parameterType { set; get; }
        /// <summary>
        /// A register to hold whether the parameter is a input or holding
        /// </summary>
        public regType registerType;

        /// <summary>
        /// allows the internal variable to be set instead of passing a string by passing in an array
        /// </summary>
        /// <param name="words">An array represeting modbus register</param>
        public abstract void setValue(ushort[] words);

        /// <summary>
        /// Feed in an array and the function will set the values into the array
        /// </summary>
        /// <param name="words"></param>
        public abstract void getValue(ushort[] words);


        public abstract string value { set; get; }
    
        /// <summary>
        /// Represents the number of 
        /// </summary>
        public abstract int size {get;}
    }

}
